//
//  EditActionsCell.swift
//  Automobile
//
//  Created by erkebulan elzhan on 8/25/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit
import SnapKit

final class EditActionsCell: UITableViewCell {

    // MARK: - Outlets
    
    lazy var readyBtn: UIButton = {
        let btn = UIButton()
        btn.layer.cornerRadius = 15
        btn.backgroundColor = .blueColor
        btn.titleLabel?.font = .systemFont(ofSize: 17)
        btn.setTitleColor(.white, for: .normal)
        btn.setTitle("Готово", for: .normal)
        btn.snp.makeConstraints { (make) in
            make.height.equalTo(44)
        }
        return btn
    }()
    
    lazy var optionsBtn: UIButton = {
        let btn = UIButton()
        btn.layer.cornerRadius = 15
        btn.backgroundColor = .lightBlueColor
        btn.titleLabel?.font = .systemFont(ofSize: 17)
        btn.setTitleColor(.greyColor, for: .normal)
        btn.setTitle("Открыть комплектации", for: .normal)
        btn.snp.makeConstraints { (make) in
            make.height.equalTo(44)
        }
        return btn
    }()
    
    private lazy var columnStack: UIStackView = {
        let stack = UIStackView()
        stack.axis = .vertical
        stack.alignment = .fill
        stack.distribution = .fillEqually
        stack.spacing = 8
        return stack
    }()
    
    // MARK: - Init
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.addViews()
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

extension EditActionsCell: ConfigurableCell {
    func configure(data object: Any?, index: Int) {}
    func returnData() -> Any? { return nil }
}



extension EditActionsCell {
    
    private func addViews () {
        contentView.addSubview(columnStack)
        columnStack.addArrangedSubview(optionsBtn)
        columnStack.addArrangedSubview(readyBtn)
        
        columnStack.snp.makeConstraints { (make) in
            make.top.bottom.equalToSuperview().inset(16)
            make.leading.trailing.equalToSuperview().inset(16)
        }
    }
}

